package com.gitee.zycra.union.api.common.param;

import com.gitee.zycra.union.api.common.model.ApiInterfaceCase;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;

/**
 * @author zycra
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
public class AddInterfaceCaseParam {

    /**
     * 接口ID
     */
    @NotNull(message = "接口ID不能为空")
    private Long interfaceId;

    /**
     * 期望名称
     */
    @NotNull(message = "期望名称不能为空")
    private String caseName;

    /**
     * mock值
     */
    @NotNull(message = "mock值不能为空")
    private String mockValue;

    public static ApiInterfaceCase convertToApiInterfaceCase(AddInterfaceCaseParam addInterfaceCaseParam) {
        if (addInterfaceCaseParam == null) {
            return null;
        }
        return new ApiInterfaceCase()
                .setInterfaceId(addInterfaceCaseParam.getInterfaceId())
                .setCaseName(addInterfaceCaseParam.getCaseName())
                .setMockValue(addInterfaceCaseParam.getMockValue());
    }
}
